class User < ActiveRecord::Base
  attr_accessor :cpassword
  belongs_to :course

  def self.login user
    begin
      _user = User.find_by_sid(user['sid'])
    rescue
      logger.info("user not found")
      return nil
    end
    if(_user.password = user['password'])
      return _user
    else
      return nil 
    end
  end

  def user_type
    return "用户"
  end
end
